<template>
  <div class="app-container">
    <el-form ref="postForm" :model="DevicedataDetaiForm"  label-width="80px"  class="form-container">

            <el-form-item style="margin-bottom: 20px;"  label="Id:">
              <span style="width:120px;">{{DevicedataDetaiForm.id}}</span>
            </el-form-item>

            <el-form-item style="margin-bottom: 20px;"  label="dtuId:"> : {{DevicedataDetaiForm.dtuId}} </el-form-item>

            <el-form-item style="margin-bottom: 20px;"  label="customerId:"> {{DevicedataDetaiForm.customer_id}} </el-form-item>

            <el-form-item style="margin-bottom: 20px;" label="dtuKey:" >  {{DevicedataDetaiForm.dtu_key}} </el-form-item>

          <el-form-item style="margin-bottom: 20px;" label="value1:" >  {{DevicedataDetaiForm.value1}} </el-form-item>

          <el-form-item style="margin-bottom: 20px;" label="value2:" > {{DevicedataDetaiForm.value2}} </el-form-item>

          <el-form-item style="margin-bottom: 20px;" label="value3:" >  {{DevicedataDetaiForm.value3}} </el-form-item>

          <el-form-item style="margin-bottom: 20px;" label="value4:" >  {{DevicedataDetaiForm.value4}} </el-form-item>

          <el-form-item style="margin-bottom: 20px;" label="value5:" >  {{DevicedataDetaiForm.value5}} </el-form-item>

          <el-form-item style="margin-bottom: 20px;" label="value6:" >  {{DevicedataDetaiForm.value6}} </el-form-item>

          <el-form-item style="margin-bottom: 20px;" label="状态:" >  {{DevicedataDetaiForm.status|statusName()}} </el-form-item>

          <el-form-item style="margin-bottom: 20px;" label="类型:" >  {{DevicedataDetaiForm.type}} </el-form-item>

          <el-form-item style="margin-bottom: 20px;" label="创建时间:" >  {{DevicedataDetaiForm.createdt}} </el-form-item>

    </el-form>
  </div>
</template>

<script>
import Tinymce from '@/components/Tinymce'
import Upload from '@/components/Upload/singleImage3'
import MDinput from '@/components/MDinput'
import Sticky from '@/components/Sticky' // 粘性header组件
import { validateURL } from '@/utils/validate'
import { devicedataDetail } from '@/api/devicedata'
import { userSearch } from '@/api/remoteSearch'

import { CommentDropdown, PlatformDropdown, SourceUrlDropdown } from '@/components/Dropdown'

const defaultForm = {
  id:'',
  controlId: '',
  dtuId: '',
  customerId: '',
  dtuKey: '',
  value1: '',
  value2: '',
  value3: '',
  value4: '',
  value5: '',
  value6: '',
  status: 1,
  createTime: '',
  type: ''
}

export default {
  name: 'DeviceDetail',
  components: { Tinymce, MDinput, Upload, Sticky, CommentDropdown, PlatformDropdown, SourceUrlDropdown },
  props: {
    isEdit: {
      type: Boolean,
      default: false
    }
  },
  data() {
    const validateRequire = (rule, value, callback) => {
      consoel.log(value)
      if (value === '') {
        this.$message({
          message: rule.field + '为必传项',
          type: 'error'
        })
        callback(new Error(rule.field + '为必传项'))
      } else {
        callback()
      }
    }
    const validateSourceUri = (rule, value, callback) => {
      if (value) {
        if (validateURL(value)) {
          callback()
        } else {
          this.$message({
            message: '外链url填写不正确',
            type: 'error'
          })
          callback(new Error('外链url填写不正确'))
        }
      } else {
        callback()
      }
    }
    return {
      DevicedataDetaiForm: Object.assign({}, defaultForm),
      loading: false,
      userListOptions: [],
      rules: {

      }
    }
  },
  computed: {
    contentShortLength() {
      return this.DevicedataDetaiForm.content_short.length
    }
  },
  created() {
    if (this.isEdit) {
      const id = this.$route.query && this.$route.query.id
      this.fetchData(id)
    } else {
      this.DevicedataDetaiForm = Object.assign({}, defaultForm)
    }
  },
  filters: {
    statusName(status) {
      if (status===1) {
        return '正常';
      }else{
        return '异常'
      }
    }
  },
  methods: {
    fetchData(id) {
      devicedataDetail({ id: id }).then(response => {
        this.DevicedataDetaiForm = response.data.data
        console.log(this.DevicedataDetaiForm)
      }).catch(err => {
        console.log(err)
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.createPost-container {
  position: relative;
  .createPost-main-container {
    padding: 40px 45px 20px 50px;
    .postInfo-container {
      position: relative;
      @include clearfix;
      margin-bottom: 10px;
      .postInfo-container-item {
        float: left;
      }
    }
    .editor-container {
      min-height: 500px;
      margin: 0 0 30px;
      .editor-upload-btn-container {
        text-align: right;
        margin-right: 10px;
        .editor-upload-btn {
          display: inline-block;
        }
      }
    }
  }
  .word-counter {
    width: 40px;
    position: absolute;
    right: -10px;
    top: 0px;
  }
}
</style>
